const app = getApp()
var api = require('../../utils/util.js').default;
var index = 0; //便利的索引值
Page({
  data: {
    deliverList: [],
    currentDeliverList: {},
  },

  onLoad: function (options) {
    var data = {
    }
    api.vipRider(data).then(result=>{
      var dataList = new Array();
      dataList = result.data.data
      for (let i = 0; i < dataList.length; i++) {
        var singleData = new Array();
        if (dataList[i]) {
          singleData = dataList[i];
          let singleObject = {};
          singleObject = {
            openid: singleData.openid,
            pho: singleData.pho_num,
            history: singleData.history,
            details: singleData.details,
            head: singleData.img_src
          }
          this.setData({
            deliverList: this.data.deliverList.concat(singleObject)
          });
        }
      }
      console.log(this.data.deliverList);
    })
  },

  // 选择骑手
  confirm: function (event) {
    index = event.currentTarget.dataset.index;
    wx.setStorageSync('select_rider', this.data.deliverList[index].openid);
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2]; //上一个页面
    prevPage.checkRider();
    wx.navigateBack({
      delta: 1 // 返回上一级页面。
    })
    console.log(wx.getStorageSync('select_rider'))
  },
 
  onPullDownRefresh: function () {
    setTimeout(() => {
      this.refreshView.stopPullRefresh()
    }, 2000)
  }


})